﻿using A.M.ETO;
using L.M.System.Application.IServices;
using L.M.System.Domain.DTO;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace L.M.System.Read.API.Controllers
{
    /// <summary>
    /// 基于角色的按钮权限
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Role_button_permissionsReadController : ControllerBase
    {
        private readonly IRole_button_permissionsServices role_Button_PermissionsServices;
        public Role_button_permissionsReadController(IRole_button_permissionsServices role_Button_PermissionsServices)
        {
            this.role_Button_PermissionsServices = role_Button_PermissionsServices;
        }


        /// <summary>
        /// 获取该角色的所有按钮权限进行反填
        /// </summary>
        /// <param name="rId">角色编号</param>
        /// <returns>获取该角色的所有按钮权限进行反填</returns>
        [HttpGet]
        public async Task<IActionResult> GetRoleButtonInfor(string? rId)
        {
            return Ok(await role_Button_PermissionsServices.GetRoleButtonInfor(rId));
        }


        /// <summary>
        /// 获取每个界面的权限
        /// </summary>
        /// <param name="roleButton"></param>
        /// <returns>获取每个界面的权限</returns>
        [HttpPost]
        public async Task<IActionResult> GetRoleNumber(RoleButton roleButton)
        {
            return Ok(await role_Button_PermissionsServices.GetRoleNumber(roleButton));
        }

    }
}
